package org.sidora.strata.feature;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.windows.TopComponent;

/**
 * Action which shows Feature component.
 * @author Enric Tartera, Juan Manuel Gimeno, Roger Masgoret
 * @version 1.0
 */
public class FeatureAction extends AbstractAction {
    
    public FeatureAction() {
        super(NbBundle.getMessage(FeatureAction.class, "CTL_FeatureAction"));
        putValue(SMALL_ICON, new ImageIcon(Utilities.loadImage(FeatureTopComponent.ICON_PATH, true)));
    }
    
    public void actionPerformed(ActionEvent evt) {
        TopComponent win = FeatureTopComponent.findInstance();
        win.open();
        win.requestActive();
    }
    
    public void actionPerformed(){
        FeatureTopComponent win = FeatureTopComponent.findInstance();
        win.open();
        win.requestActive();
        win.fillFeatureItems();
    }

    public TopComponent getTopComponent(){
        return FeatureTopComponent.findInstance();
    }
    
    public void emptyFields(){
        FeatureTopComponent win = FeatureTopComponent.findInstance();
        win.emptyFeaturetItems();
    }
    
    public void saveFields(){
        FeatureTopComponent win = FeatureTopComponent.findInstance();
        win.saveFeatureFields();
    }
    
    public void cerrar(){
           FeatureTopComponent win = FeatureTopComponent.findInstance();
           win.close();
    }
}
